<template>
	<view>
		<!-- 操作菜单 -->
		<!-- 模态框 -->
		<paperLeftPopup :show="show" @addfriend='addfriend' @hiddenpopup='hiddenpopup' @clear="clear"></paperLeftPopup>
		<!-- 小纸条列表 -->
		<block v-for="(item,index) in list" :key="index">
			<paper-list :item="item"  @tap="toUserChat"></paper-list>
		</block>
		<load-more :loadtext='loadtext'></load-more> 
		
		<!-- <uni-badge text="123" type="error" /> -->
	</view>
</template>

<script>
	import loadMore from '../../components/common/load-more.vue'
	import paperList from '../../components/paper-list/paper-list.vue'
	import paperLeftPopup from '../../components/paper-list/paper-left-popup.vue'
	export default {
		components:{
			paperList,
			loadMore,
			paperLeftPopup
		},
		data() {
			return {
				show:false,
				loadtext:"上拉加载更多",
				list:[
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺111",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺222",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺333",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:0
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺444",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:0
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:0
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:0
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:2
					},
					{
						userpic:"../../static/demo/userpic/12.jpg",
						username:"JIA一勺",
						time:"13:58",
						data:"赵丽颖《知否》一句话打脸，“读书...”",
						noreadnum:0
					}
				]
			}
		},
		// 监听下拉刷新事件
		onPullDownRefresh() {
			this.getdata()
		},
		// 监听页面触底事件
		onReachBottom(){
			this.loadMore()
		},
		// 监听导航栏按钮
		onNavigationBarButtonTap(e){
			switch(e.index){
				case 0: 
				console.log('点击了左边按钮')
				uni.navigateTo({
					url:'../user-list/user-list'
				})
				this.hiddenpopup()
				break;
				case 1:
				this.show = !this.show;
				
			}
		},
		methods: {
			toUserChat(){
				uni.navigateTo({
					url:'../../pages/user-chat/user-chat'
				})
			},
			// 添加糗友
			addfriend(){
				console.log('加糗友')
				this.hiddenpopup()
			},
			// 清楚缓存
			clear(){
				console.log('清除缓存');
				this.hiddenpopup()
			},
			// 隐藏popup
			hiddenpopup(){
				this.show = false
			},
			// 显示popup
			showpopup(){
				this.show = true
			},
			// 上拉加载更多
			loadMore(){
				let obj = {
					userpic:"../../static/demo/userpic/12.jpg",
					username:"JIA一勺666",
					time:"13:58",
					data:"赵丽颖《知否》一句话打脸，“读书...”",
					noreadnum:66
				}
				this.loadtext = '加载中...'
				setTimeout(()=>{
					this.list.push(obj)
					this.loadtext = '上拉加载更多'
				},2000)
				
			},
			// 下拉刷新
			getdata(){
				setTimeout(()=> {
					// 获取数据
					let arr = [
						{
							userpic:"../../static/demo/userpic/12.jpg",
							username:"JIA一勺1111",
							time:"13:58",
							data:"赵丽颖《知否》一句话打脸，“读书...111111”",
							noreadnum:2
						},
						{
							userpic:"../../static/demo/userpic/12.jpg",
							username:"JIA一勺2222",
							time:"13:58",
							data:"赵丽颖《知否》一句话打脸，“读书...”",
							noreadnum:2
						},
						{
							userpic:"../../static/demo/userpic/12.jpg",
							username:"JIA一勺333333",
							time:"13:58",
							data:"赵丽颖《知否》一句话打脸，“读书...”",
							noreadnum:0
						}
					];
					// 赋值
					this.list = arr
					// 关闭下拉刷新 
					uni.stopPullDownRefresh()
				}, 1000);
				
			}
		}
	}
</script>

<style>
	
 
</style>
